package com.oasis.cloud.browser.adapter;

import com.oasis.cloud.core.handler.OasisSuccessHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

@EnableWebSecurity
@EnableAutoConfiguration
public class OasisWebSecurityConfigAdapter extends WebSecurityConfigurerAdapter {

    //@Autowired
    //private OasisSuccessHandler oasisSuccessHandler;


    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.formLogin().
                loginPage("/login.html").//successHandler(oasisSuccessHandler).
                loginProcessingUrl("/oasis/login").and().authorizeRequests().
                antMatchers("/login.html").permitAll().
                anyRequest().authenticated().and().csrf().disable();
        ;
    }
}
